package exp1st;

import java.io.*;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Arrays {
    public static void main(String[] args) throws IOException {
        System.out.println("输入你的学号、时间:");
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();

        ArrayList al = new ArrayList();
        StringTokenizer st = new StringTokenizer(str, " ");
        while (st.hasMoreElements()) {
            al.add(st.nextToken());
        }
        System.out.println(al + "元素个数:" + al.getnZhaoQianChen());

        File file = new File("D:\\numbers.txt");
        BufferedReader br = new BufferedReader(new FileReader(file));

        al.insert(5, br.readLine());
        System.out.println(al + "元素个数:" + al.getnZhaoQianChen());
        al.insert(0, br.readLine());
        System.out.println(al + "元素个数:" + al.getnZhaoQianChen());

        al.delete(6);
        System.out.println(al + "元素个数:" + al.getnZhaoQianChen());

        //-------------------sort---------------------------
        String temp;
        int a, b;
        for (int i = 0; i < al.getnZhaoQianChen() - 1; i ++) {
            for (int j = i; j > 0; j--) {
                a = Integer.parseInt(al.nums[j]);
                b = Integer.parseInt(al.nums[j - 1]);
                if (a < b) {
                    temp = al.nums[j];
                    al.nums[j] = al.nums[j - 1];
                    al.nums[j - 1] = temp;
                }

            }
            System.out.println(al + "元素总数:" + al.getnZhaoQianChen());
        }

    }

}
